package com.rocky_tech.service.impl;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.rocky_tech.biz.DecideForm;
import com.rocky_tech.framework.struts.form.ActionForm;
import com.rocky_tech.service.DecideService;
import com.rocky_tech.service.vo.MessageVO;

public class DecideServiceImpl implements DecideService {

	@Override
	public Map<String,MessageVO>  getVO(HttpServletRequest request,HttpServletResponse response,ActionForm form,Map<String, String> actionForwards) {
		
		//String username = request.getParameter("username");
		System.out.println(form);
		DecideForm decideForm = (DecideForm)form;
		String username = decideForm.getUserName();
		Map<String,MessageVO> map = new HashMap<String,MessageVO>();
		boolean b = false;
		MessageVO mess = new MessageVO();
		String message = "";
		String url = "";
		b = this.isuser(username);
		if (b) {
			//url = "/view/success.jsp";
			url = actionForwards.get("success");
			message = "成功！";
		}else{
			//url = "/view/fail.jsp";
			url = actionForwards.get("fail");
			message = "失败！";
		}
		mess.setMessage(message);
		mess.setName(username);
		map.put(url, mess);
		return map;
	}
	
	
	//判断用户名输入的字符串是否是"zzc"
		private boolean isuser(String username){
			boolean b = false;
			if (username.equals("zzc")){
				b = true;
			}
			return b;
		}

}
